<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>

    const name = ['nba','abc','nba']
    
    // const findItem = name.find((item,index,arr) => {  // 原生
    //     console.log(item,index,arr);  
    //     return true
    // })


    Array.prototype.myFind = function(callback){ // 手写
        for(let i = 0; i < this.length; i++){
            let isFlag = callback(this[i],i,this)
            if(isFlag){
                return this[i]
            }
        }
    }

    const findItem = name.myFind((item,index,arr) => {
        if(item === 'abc'){
            return true
        }
    })

    console.log(findItem);

    </script>

</body>
</html>